<?php

class Application_Form_UserManage extends Zend_Form {

    public function init() {
        $this->setName('add_user');

        $id = new Zend_Form_Element_Hidden('nuser');

        $nom = new Application_Form_InText('nom', 'form_user_add_name');

        $prenom = new Application_Form_InText('prenom', 'form_user_add_firstname');

        $email = new Application_Form_InText('email', 'form_user_add_mail');
        $email->addValidator('EmailAddress')->addValidator(new Zend_Validate_Db_NoRecordExists('users', 'email'));

        $password = new Zend_Form_Element_Password('password');
        $password->setLabel('form_user_add_password')->addFilter('StripTags')->addFilter('StringTrim')->setRequired(true);

        $password2 = new Zend_Form_Element_Password('password2');
        $password2->setLabel('form_user_add_password2')->addFilter('StripTags')->addFilter('StringTrim');

        $active = new Zend_Form_Element_Checkbox('active');
        $active->setLabel('form_user_add_enable')->addFilter('StripTags')->addFilter('StringTrim')->setValue(1);

        $level = new Zend_Form_Element_Select('level');
        $level->setLabel('form_user_add_level')->addFilter('StripTags')->addFilter('StringTrim');
        $levelOptions = array();
        for ($i = 0; $i <= 9; $i++) {
            $levelOptions [$i] = array('key' => $i, 'value' => $i);
        }
        $level->addMultiOptions($levelOptions);

        $submit = new Zend_Form_Element_Submit('submit');
        $submit->setAttrib('id', 'submitbutton')->setLabel('form_user_add_submit');

        $elements = array($id, $nom, $prenom, $email, $password, $password2, $active, $level, $submit);
        $this->addElements($elements);
    }

}

